////////////////////////////////////////////////////////////////////////////////
//
//  Pixelami.com
//  Copyright 2011 Original Authors (Alexander Syed et al)
//  All Rights Reserved.
//
//  NOTICE: Pixelami permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

package org.pixelami.hercularity.descriptors
{
	import flash.events.ErrorEvent;
	import flash.events.Event;
	import flash.events.IEventDispatcher;
	
	import org.pixelami.hercularity.ab_internal;
	
	
	public class Action
	{
		static public const BREAK_ON_ERROR:Boolean = true;
		static public const PROCEED_ON_ERROR:Boolean = false;
		
		
		
		
		
		private var _target:IEventDispatcher;
		
		

		public function get target():IEventDispatcher
		{
			return _target;
		}

		public function set target(value:IEventDispatcher):void
		{
			_target = value;
		}


		/**
		 * The Event type that signifies the task completed successfully
		 */
		public var successEventType:String;
		
		/**
		 * The Event type that signifies the task failed
		 */
		public var failureEventType:String;
		
		/**
		 * A flag to specify whether the Step should fail completely is this Action fails
		 */
		public var breakOnFailure:Boolean;
		
		/**
		 * The method name that starts the task
		 */
		public var runMethodName:String;
		
		
		/**
		 * Store an instance of the error event
		 */
		ab_internal var errorEvent:Event;
		
		
		public function get errorEvent():Event
		{
			return ab_internal::errorEvent;
		}
		
		/**
		 * 
		 * @param target
		 * @param breakOnFailure
		 * @param successEventType
		 * @param failureEventType
		 * @param runMethodName
		 * 
		 */
		
		public function Action(target:IEventDispatcher,breakOnFailure:Boolean=false,
							   successEventType:String=Event.COMPLETE,failureEventType:String=ErrorEvent.ERROR,
							   runMethodName:String="start")
		{
			this.target = target;
			this.breakOnFailure = breakOnFailure;
			this.successEventType = successEventType;
			this.failureEventType = failureEventType;
			this.runMethodName = runMethodName;
		}
	}
}